<div class="fm-content">
  <div class="title">
    <i nz-icon [type]="'desktop'"></i>
    &nbsp;&nbsp;APP版本管理
  </div>
  <div class="work">
    <div class="top">
      <nz-select class="fm-input first-input" [(ngModel)]="fs.queryObject['infoid']" name="infoid"
        (nzOpenChange)="appDic.load('0')" [nzPlaceHolder]="'APP名称'">
        <nz-option *ngFor="let option of appDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
        </nz-option>
        <nz-option *ngIf="appDic.isLoading" nzDisabled nzCustomContent>
          <i nz-icon type="loading" class="loading-icon"></i>加载中...
        </nz-option>
      </nz-select>
      <input nz-input placeholder="版本号" class="fm-input" [(ngModel)]="fs.queryObject['version:like']" />
      <nz-button-group class="fm-search-input">
        <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
          <button nz-button (click)="fs.editRow()">编辑</button>
          <button nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntitys()" nzPlacement="bottomRight"
            nz-button>删除</button>
        </nz-button-group>
      </div>
    </div>

    <div class="work-content">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger [nzPageSizeOptions]='[ 10, 15, 20, 30, 40, 50 ]'
          [nzFrontPagination]="false" [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing"
          [nzTotal]="fs.rowsCount" [(nzPageIndex)]="fs.pageIndex" [(nzPageSize)]="fs.pageSize"
          (nzPageIndexChange)="fs.loadData()" (nzPageSizeChange)="fs.loadData(true)">
          <thead (nzSortChange)="fs.sort($event)" nzSingleSort>
            <tr>
              <th nzShowCheckbox [(nzChecked)]="fs.allChecked" [nzIndeterminate]="fs.indeterminate"
                (nzCheckedChange)="fs.checkAll($event)"></th>
              <th>应用</th>
              <th>版本号</th>
              <th>版本编号</th>
              <th>更新内容</th>
              <th>更新时间</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let data of fs.datas">
              <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="fs.refreshCheckStatus()">
              </td>
              <td><span (click)="fs.editRow(data)" class="form-edit">{{data.version}}</span></td>
              <td>{{data.numversion}}</td>
              <td>{{data.content}}</td>
              <td>{{data.createtime | date:'yyyy-MM-dd HH:mm:ss' }}</td>
            </tr>
          </tbody>
        </nz-table>
      </div>
    </div>

    <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="fs.isEditVisible"
      (nzOnCancel)="fs.closeEdit()">
      <form nz-form [nzLayout]="'inline'">
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">应用</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="infoid.invalid?'error':'success'"
                nzHasFeedback>
                <nz-select class="form-control" [(ngModel)]="fs.er.infoid" name="infoid" #infoid="ngModel" 
                  (nzOpenChange)="appDic.load('0')" [nzPlaceHolder]="'APP名称'">
                  <nz-option *ngFor="let option of appDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
                  </nz-option>
                  <nz-option *ngIf="appDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading" class="loading-icon"></i>加载中...
                  </nz-option>
                  <span *ngIf="!appDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.infoName" [nzValue]="fs.er.infoid">
                    </nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">版本号</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="version.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input [(ngModel)]="fs.er.version" name="version" required #version="ngModel" />
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">版本编号</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="numversion.invalid?'error':'success'"
                nzHasFeedback>
                <nz-input-number [(ngModel)]="fs.er.numversion" name="numversion" required #numversion="ngModel"
                  [nzMin]="1" [nzMax]="100" [nzStep]="1" class="form-control">
                </nz-input-number>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">上传</nz-form-label>
              <nz-form-control class="form-control">
                <nz-upload nzAction="{{ ffs.getUploadUrl() }}" [nzMultiple]="false"
                  [nzShowUploadList]="{ showPreviewIcon: true, showRemoveIcon: fs.er.FIELD_ISNEW }"
                  [(nzFileList)]="fs.er.appfile" name="appfile" (nzChange)="ffs.handleChange($event)">
                  <button nz-button [disabled]="!fs.er.FIELD_ISNEW"><i nz-icon
                      type="upload"></i><span>上传</span></button>
                </nz-upload>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">更新时间</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="createtime.invalid?'error':'success'"
                nzHasFeedback>
                <nz-date-picker nzShowTime [(ngModel)]="fs.er.createtime" name="createtime" required
                  #createtime="ngModel"></nz-date-picker>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">更新内容</nz-form-label>
              <nz-form-control class="form-control3" [nzValidateStatus]="content.invalid?'error':'success'"
                nzHasFeedback>
                <textarea nz-input [(ngModel)]="fs.er.content" name="content" required #content="ngModel"></textarea>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24" class="form-button-align">
            <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
            <button nz-button nzType="primary"
              [disabled]='infoid.invalid || version.invalid || numversion.invalid || createtime.invalid || content.invalid'
              (click)="fs.save()" [nzLoading]="fs.isSaveing">保存</button>
          </div>
        </div>
      </form>
    </nz-modal>
  </div>
</div>